import json

import nacos

SERVER_ADDRESSES = "172.20.10.2:8848"
NAMESPACE = "817df357-e937-4ef1-bd43-1a2a3649e72b"  # name space id

# auth mode
client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE, username="nacos", password="nacos")

# get config
data_id = "user-srv.json"
group = "dev"

# print(client.get_config(data_id, group))  # 返回str
json_data = json.loads(client.get_config(data_id, group))


def test_cb(args):
    print("配置文件产生变化")
    print(args)


if __name__ == "__main__":
    client.add_config_watchers(data_id, group, [test_cb])

    import time
    time.sleep(3000)
